import mysql_config
import MySQLdb

class MySQLHandler:
    def __init__(self):
        self.conn = 0
    def MySQLConnect(self):
        conf = mysql_config.get_config()
        conn = MySQLdb.connect(conf[0],conf[1],str.decode(conf[2],'base64'),conf[3])
        self.conn = conn
        return conn
    def DoQuery(self,query):
        cursor = self.conn.cursor()
        cursor.execute(query)
        q = cursor.fetchall()
        cursor.close()
        return q
    def Close(self):
        self.conn.close()

"""handler = MySQLHandler()
conn = handler.MySQLConnect()
query = handler.DoQuery("SELECT * FROM user",conn)
print query
handler.Close(conn)

    usr = raw_input("Username:")
    pw = getpass.getpass("Password:")
    pw2 = getpass.getpass("Confirm:")

    if pw != pw2:
        print "You failed at typing your Password"
    print usr,pw,pw2
"""
